clc;clear;
wrdLn = 15; quant_num = 10000;

z = double(fi(0.29, 1, wrdLn));
u = double(fi(1023 + 0i, 1, wrdLn));
x = real(u); y = imag(u); theta = z*quant_num;

for iter=0:wrdLn-1
    angle = quant_num*2^(-iter);
    if (theta > 0)
        new_y = y + x*(2^(-iter));
        theta = theta - angle;
    else
        new_y = y - x*(2^(-iter));
        theta = theta + angle;
    end
    y = new_y;
end
v = y;
fprintf('1023*0.29 = %d\n',int16(1023*0.29));
fprintf('input:x = %d,z(量化) = %.2f*%d\noutput %d\n',x,z,quant_num,int16(v));

